<template>

		<header class="header">

		</header>
</template>

<script>
import LOGO from '@/assets/images/logo.png'

export default {
	name: "LayoutHeader",
	data(){
		return {
			showMenu: false,
			logo: LOGO,
			productNodes: [],
			solutionNodes: []
			
			
		}
	},
	mounted() {
		this.initData();
	},
	watch:{
		'$store.state.globalClickEvent'(e){
			this.showMenu = false;

		}
	},
	computed:{
		navigateItems(){
			return [
				{ path: '/', group: '',  label: '首页'},
				{ path: '/product',  group: 'product', label: '产品', nodes: this.productNodes},
				{ path: '/solution',  group: 'solution', label: '解决方案', nodes: this.solutionNodes},
				{ path: '/download', group: 'service', label: '服务与支持'},
				{ path: '/introduce', group: 'about',  label: '关于我们'}]
		},
		href(){
			return (item) => {

				if(this.active(item)){
					return ''
				}
				return item.path;
			}
		},
		active(){
			return (item)=> {
				return this.$route.path == item.path  || this.$route.meta && item.group  == this.$route.meta.group;
			}

		}

	},
	methods:{
		home(){
			this.$router.replace({
				path: '/'
			})
		},
		to(item){
			this.showMenu = false;
			let href = this.href(item);
			
			if(href){
				navigateTo({
					url: href
				})
			}
		},
		initData(){
			
		},
		onMenuChange(e){
			if(e.group == 'product'){
				let arr = e.value.split('_');
				let type = arr[0];
				let id = arr[1] * 1;
				if(type == 'product'){
					navigateTo({
						url: '/product/' + id
					})
				}
				else if(type == 'category'){
					navigateTo({
						url: '/product?catid=' + id
					})
				}
				
			}
			else if(e.group == 'solution'){
				let arr = e.value.split('_');
				let type = arr[0];
				let id = arr[1] * 1;
				if(type == 'solution'){
					navigateTo({
						url: '/solution/' + id
					})
				}
				else if(type == 'category'){
					navigateTo({
						url: '/solution?catid=' + id
					})
				}
				
			}
		}
	}
}
</script>

<style scoped lang="scss">
.header{
  transition: top 0.2s ease-in-out;
	position: fixed;
	top:-6rem;
	z-index: 100;
	height: 6rem;
	padding: 0rem 0;
	box-sizing: content-box;
	background:rgba(35,35,35,.8);
	color: #FFFFFF;
	/*font-family: PingFang SC, PingFang SC;*/
	font-weight: 500;
	font-size: 1.1rem;
	line-height: 1.05rem;
	text-align: left;
	font-style: normal;
	text-transform: none;

	.header-inner{
		height: 100%;
		display: flex;
		width: 96rem;
		align-items: center;
		padding-left: 4.7rem;

		.logo{
			height: 4.1rem;
		}

		.icon-menu{
			display: none;
		}

		.navigate-bar{
			margin-left: 18rem;
			width: 44rem;
			display: flex;
			position: relative;
			height: 100%;
			align-items: center;
			justify-content: space-between;

			.nav-item{
				line-height: 6rem;
				height: 6rem;
				flex:1;
				text-align: center;
				margin: 0 0.2rem;
				cursor: pointer;

			}
			.active{
				position: relative;
				&::after{
					content: '';
					display: block;
					width: 0.5rem;
					height: 0.1rem;
					position: absolute;
					bottom:1.95rem;
					background: #FFFFFF;
					left: 50%;
					transform: translateX(-50%);

				}
			}
		}

    .mobile-navigate-bar{
      display: none;
    }
    .pc-navigate-bar{
      display: flex;
    }
	}

}

/* 最大宽高比 7/8 或者 宽度小于768 手机模式 */
@media (max-aspect-ratio: 7/8) , (max-width: 768px) {
	.header{
		height: 4.5rem;
		width: 100%;
		padding:0;
    top:0;
    background:rgba(35,35,35,.2);
		.header-inner{
			position: relative;
			padding:0.95rem 0;
			width: 100%;
			display: flex;
			justify-content: space-between;


			.logo{
				width: 8.55rem;
				height: 2.6rem;
				margin-left: 1.2rem;

			}

			.icon-menu{
				display: block;
				background: none;
				color: #FFFFFF;
				border: none;
				font-size: 1.55rem;
				width: 3.4rem;
				text-align: center;
				padding:0;
				margin-left: 0;
				margin-right: 0.7rem;

			}

			.navigate-bar{
				position: absolute;
				left: 0;
				right: 0;
				margin:0;
				width: 100%;
				top: 100%;
        background:rgba(35,35,35,.2);
				flex-direction: column;
				display: none;

				&.active{
					display: flex;
          justify-content: flex-start;
          align-items: flex-start;
          height: auto;
				}

				&:before{
					display: block;
					content: '';
					width: 0;
					height: 0;
					position: absolute;
					right: 1.55rem;
					bottom: 100%;
					border-top: 0rem solid transparent;
					border-right: 0.75rem solid transparent;
					border-left: 0.75rem solid transparent;
					border-bottom: 1rem solid rgba(0, 0, 0, 0.70);
				}

				.nav-item{
					padding-left: 2.75rem;
					line-height: 4rem;
					height: 4rem;
					font-weight: 500;
					font-size: 1.6rem;
					margin-bottom: 1rem;

					&.active::after{
						left: 2.75rem;
						transform: none;
						width:3.2rem;
						height: 0.25rem;
						border-radius: 0.05rem;
						bottom: 0.25rem;
					}
				}
			}


      .pc-navigate-bar{
        display: none;
      }


		}



	}
}


</style>

